#![allow(dead_code)]
use apperror::{AnyError, AnyErrorExt};
use tauri::{async_runtime::spawn, AppHandle, Emitter};

#[tauri::command]
pub fn seir_predict(username: String, filename: String, app: AppHandle) {
    spawn(async move {
        match seir_predict_handler(username, filename).await {
            Ok(_) => app.emit("seir_predict", Ok::<&str, &str>("预测成功")),
            Err(_) => app.emit("seir_predict", Err::<&str, &str>("预测失败")),
        }
    });
}

async fn seir_predict_handler(username: String, filename: String) -> Result<(), ()> {
    tonic_ffi_client::predict_by_seir(filename, username)
        .await
        .map_err(|e| {
            log::error!("{}", AnyError::establish(e).report());
        })?;
    Ok(())
}

#[tauri::command]
pub fn sir_predict(_username: String, _filename: String) {
    todo!();
}

async fn sir_predict_handler(_username: String, _filename: String) -> Result<(), ()> {
    Ok(())
}
